<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
	<title>DHTML Tree samples. dhtmlXTree - Smart XML parsing and Sorting</title>
</head>
<style>
	body {font-size:12px}
	.{font-family:arial;font-size:12px}
	h1 {cursor:hand;font-size:16px;margin-left:10px;line-height:10px}
	xmp {color:green;font-size:12px;margin:0px;font-family:courier;background-color:#e6e6fa;padding:2px}
</style>
<body>
	<h1>Smart XML parsing and Sorting</h1>
	<link rel="STYLESHEET" type="text/css" href="../css/dhtmlXTree.css">
	<script  src="../js/dhtmlXCommon.js"></script>
	<script  src="../js/dhtmlXTree.js"></script>
	<script  src="../js/dhtmlXTree_sb.js"></script>
    Try to sort nodes in first tree.<br/>
    Try to drag nodes in second tree, dropped item will set its order based on ASC sorting.
    <br>Both tree loaded in SmartXMLParsing mode, which allow to operate with huge well formed trees.    
	<table>
		<tr>
			<td>
				<div id="treeboxbox_tree" style="width:250; height:218;background-color:#f5f5f5;border :1px solid Silver;; overflow:auto;"></div>
				<div id="treeboxbox_tree2" style="width:250; height:218;background-color:#f5f5f5;border :1px solid Silver;; overflow:auto;"></div>
			</td>
			<td rowspan="2" style="padding-left:25" valign="top">
				<a href="#" onclick="tree.sortTree(tree.getSelectedItemId(),'ASC',1);">Reorder selected branch (ASC)</a><br>
				<a href="#" onclick="tree.sortTree(tree.getSelectedItemId(),'DES',1);">Reorder selected branch (DES)</a><br>
			</td>
		</tr>
		<tr>
			<td>
			</td>
		</tr>
	</table>
<hr>
<XMP>
<div id="treeboxbox_tree" style="width:200;height:200"></div>
<script>
	tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);
		tree.setImagePath("../imgs/");
		tree.enableSmartXMLParsing(true);	 //enable smart parsing
		tree.loadXML("tree.xml");
		....
		//sorting
		tree.sortTree(tree.getSelectedItemId(),'ASC',1);
		tree.sortTree(tree.getSelectedItemId(),'DES',1);
</script>
</XMP>
	<script>
function treeDrop(id, target, target_before, tree_source, tree_dest) {
tree_dest.sortTree(target,'ASC',0);
}

			tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);
			tree.setImagePath("../imgs/");
			tree.enableSmartXMLParsing(true);
			tree.enableCheckBoxes(true);
            tree.enableDragAndDrop(true);
			tree.enableThreeStateCheckboxes(true);
			tree.loadXML("tree.xml")

tree.setDropHandler(treeDrop);


			tree2=new dhtmlXTreeObject("treeboxbox_tree2","100%","100%",0);
			tree2.setImagePath("../imgs/");
			tree2.enableSmartXMLParsing(true);
			tree2.enableCheckBoxes(true);
            tree2.enableDragAndDrop(true);
			tree2.enableThreeStateCheckboxes(true);
		    tree2.loadXML("tree.xml")

tree2.setDropHandler(treeDrop);




	</script>
<br><br>

</body>
</html>
